import { t } from 'i18next'
import React, { FC } from 'react'
import { ItemActionWrap } from '../../../../../../components'
import { OperateIconComponent, operateType } from './component'
import { DcsModel } from '@/api/manager/dcs/interface'
import { Mt } from '@/api/manager/mt'
const useOperate = (mcc: Mt, dcs: DcsModel['dcs']): operateType[] => {
	//是否在线
	if (mcc.status.isOnline) {
		if (dcs.isApply) {
			return ['dcsApply', 'dcsRefuse', 'delete', 'online']
		} else {
			if (dcs.isDcs) {
				return ['dcs', 'delete', 'online']
			} else {
				return ['dcs', 'delete']
			}
		}
	} else {
		return ['dcs', 'delete', 'offline']
	}
}
export const ItemAction: FC<DcsModel> = ({ mcc, status, dcs }) => {
	const icon = useOperate(mcc, dcs)
	return (
		<ItemActionWrap>
			{!status.isCalling ? (
				<div className="action-icons">{icon.map((x) => OperateIconComponent[x](mcc, { dcs }))}</div>
			) : (
				<div className="isCalling">{t('正在呼叫中...')}</div>
			)}
		</ItemActionWrap>
	)
}
